home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / blix / blixfont.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.2 KB  |  90 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*_______________________________________________________________________
  18.  |
  19.  | blixfont.c - generates the font for the hishscore and the intro screen
  20.  | 
  21.  | (C) 1994 Frans van Hoesel, Xtreme Graphics Software.
  22.  */
  23.  
  24. #include <gl/gl.h>
  25. #include <gl/device.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29.  
  30. #include "blix.h"
  31. #include "blixfont.h"
  32. #include "haeberlifont.h"
  33.  
  34. static long xwinsize, ywinsize;
  35. static float fsize = 0.1;
  36. static objfnt *fnt;
  37.  
  38. void init_fonts(void) {
  39.     char fullpath[512];
  40.     FILE *f;
  41.     
  42.     strcpy(fullpath, datadir);
  43.     strcat(fullpath, "Honesty.of");
  44.     f = fopen(fullpath, "r");
  45.     if (f == NULL) {
  46.     strcpy(fullpath, "Honesty.of");
  47.         f = fopen(fullpath, "r");
  48.     if (f == NULL) {
  49.         fprintf(stderr,"cannot open font file Honesty.of\n");
  50.         gexit();
  51.         exit(1);
  52.     }
  53.     }
  54.     fnt = readobjfnt(fullpath);
  55.     if(!fnt ) {
  56.     fprintf(stderr,"meshfont: can't open font\n");
  57.     exit(1);
  58.     } 
  59. }
  60.  
  61. void set_fontsize(float size) {
  62.     
  63.     getsize(&xwinsize, &ywinsize);
  64.     size = size * ywinsize;
  65.     aafontsetsize(fnt, size);
  66.     fsize = size;
  67. }
  68.  
  69. void set_fontcolor(unsigned long c1, unsigned long c2) {
  70.  
  71.     charsetcolors(c1, c2);
  72. }
  73.  
  74. void draw_stringXY(float x, float y, char *s) {
  75.  
  76.     int c;
  77.     float xpos, ypos;
  78.     x = x * xwinsize;
  79.     y = y * ywinsize;
  80.     aafontmoveto(x, y);
  81.     if (s == NULL) return;
  82.     while ( (c = *s++) != '\0' ) {
  83.     get_charpos(&xpos, &ypos);
  84.     drawaafntchar(fnt,c);
  85.     if ( c == '\n') {
  86.         aafontmoveto(x, ypos-fsize);
  87.     }
  88.     }
  89. }
  90.